<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录-会员平台</title>
    <!-- 样 式 文 件 -->
    <link rel="stylesheet" href="/app/admin/component/pear/css/pear.css"/>
    <link rel="stylesheet" href="/app/admin/admin/css/pages/login.css"/>
</head>
<style>
    .zyl_lofo_main {
        background-color: rgba(255, 255, 255, 0.9);
        padding: 10px 20px;
    }

    .layui-elem-field legend {
        margin-left: 0;
        padding: 0;
        width: 100%;
        text-align: center;
        align-content: center;
    }
</style>
<!-- 代 码 结 构 -->
<body background="/app/admin/admin/images/background.svg" style="background-size: cover;">

<form class="layui-form zyl_lofo_main">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>登录-会员平台</legend>
    </fieldset>
    <div class="layui-form-item">
        <input lay-verify="required" hover class="layui-input" type="text" name="username" value="" placeholder="用户名"/>
    </div>
    <div class="layui-form-item">
        <input lay-verify="required" hover class="layui-input" type="password" name="password" value=""
               placeholder="密码"/>
    </div>
    <div class="layui-form-item">
        <input hover lay-verify="required" class="code layui-input layui-input-inline" name="captcha"
               placeholder="验证码"/>
        <img class="codeImage" width="120px"/>
    </div>
    <div class="layui-form-item">
        <button type="submit" class="pear-btn pear-btn-primary login" lay-submit lay-filter="login">
            登 录
        </button>
        <div class="layui-form-item" style="text-align: right">

            <?php if ($link_id): ?>
            <small>
                <a href="/app/register?invitation=<?=$invitation?>&link_id=<?=$link_id?>">去注册</a>
            </small>
            <small>
                <a href="/app/forget?invitation=<?=$invitation?>&link_id=<?=$link_id?>">忘记密码?</a>
            </small>
            <?php else: ?>
            <small>
                <a href="/app/register?invitation=<?=$invitation?>">去注册</a>
            </small>
            <small>
                <a href="/app/forget?invitation=<?=$invitation?>">忘记密码?</a>
            </small>
            <?php endif; ?>

        </div>
    </div>
</form>

<script>
    var color = localStorage.getItem("theme-color-color");
    var second = localStorage.getItem("theme-color-second");
    if (!color || !second) {
        localStorage.setItem("theme-color-color", "#2d8cf0");
        localStorage.setItem("theme-color-second", "#ecf5ff");
    }
</script>
<!-- 资 源 引 入 -->
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
<script src="/app/admin/component/pear/pear.js"></script>
<script>
    layui.use(['form', 'button', 'popup', 'layer', 'theme', 'admin'], function () {

        var $ = layui.$, layer = layui.layer, form = layui.form;

        function switchCaptcha() {
            $('.codeImage').attr("src", "/app/admin/account/captcha/login_user?v=" + new Date().getTime());
        }

        switchCaptcha();
        // 登 录 提 交
        form.on('submit(login)', function (data) {
            layer.load();
            $.ajax({
                url: '/app/admin/account/login_user',
                type: "POST",
                dataType: "JSON",
                data: data.field,
                success: function (res) {
                    layer.closeAll('loading');
                    if (!res.code) {
                        layui.popup.success(res.msg, function () {
                            window.location.href = "/app/admin";
                            // location.reload();
                        })
                    } else {
                        layui.popup.failure(res.msg)
                        switchCaptcha();
                    }
                }
            });
            return false;
        });
        $('.codeImage').on('click', function () {
            switchCaptcha();
        });
    })
</script>
</body>
</html>
